import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    token: null
  },
  mutations: {
    setToken (state, newToken) {
      state.token = newToken
      localStorage.setItem('token', newToken)
    }
  },
  actions: {
    signOut (context) {
      localStorage.removeItem('token')
    }
  }
})

export default store
